package com.psm.controller;

import java.util.List;

import com.jfinal.log.Logger;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.render.JsonRender;
import com.jfinal.upload.UploadFile;
import com.psm.model.PuContent;
import com.psm.model.PuContentPic;

public class PzonecController extends BaseController<PuContent>{
	
	public Logger logger = Logger.getLogger(getClass());
	
	public void index(){
        render("index.html");
    }
	public void listJson(){
		List<Record> list = PuContent.me.listJson(10, 1);
//		for(Record l:list){
//			int id = l.getInt("id");
//			List<PuContentPic> plist = PuContentPic.me.find("select * from pu_content_pic where pid="+id);
//        }
		setAttr("list", list);
		render(new JsonRender().forIE());
	}
	//上传相片，前台图片的标示为pic
	public void upload(){
		System.out.println("go into pzone upload");
		String seq_id = System.currentTimeMillis()+"";
		System.out.println(seq_id);
		UploadFile uf = getFile("pic", seq_id);
		System.out.println(uf.getFileName());
		setAttr("statu", 1);
        setAttr("path", "upload/"+seq_id+"/"+uf.getFileName());
        render(new JsonRender().forIE());
	}
	public void saveContent(){
		String[] array = getParaValues("pics");
		String content = getPara("content");
		if(array == null)
		{
			System.out.println("array is null");
		}
		else {
			System.out.println("array length is: "+array.length);
		}
	}
	public void checkNum(){
		
	}

}
